package com.achen.service.impl;

import com.achen.dao.DeptDao;
import com.achen.elasticsearch.dao.DeptRepository;
import com.achen.entity.Dept;
import com.achen.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author achen
 * @create 2020-04-30 23:10
 */
@Service
@Transactional
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptDao deptDao;
    @Autowired
    private DeptRepository deptRepository;

    @Override
    public List<Dept> findByPage(Integer page, Integer limit) {
        Integer start = (page - 1) * limit;
        return deptDao.findByPage(start,limit);
    }

    @Override
    public Integer findCount() {
        return deptDao.findByCount();
    }

    @Override
    public Map findBySearch(String querykeyword, Integer page, Integer limit) {
        Map map = deptRepository.findBySearch(querykeyword, page, limit);
        map.put("code",0);
        map.put("msg","");
        return map;
    }
}
